include <battery_18650.scad>
// battery variables
height=65;
weight=18;
head_height=2;
head_weight=6.5;

// delta

delta=0.5;
// socket thickness
thick = 5;

// metal thickness

head_metal=1;
tail_metal=5;

difference(){
    translate([0,0,-thick])
        cube([height+head_height+head_metal+tail_metal+thick*2,weight+2*thick,weight*2/3+thick],center=true);
    
    
    
    union(){
    // 电池凹槽
        rotate([0,90,0])
            battery_18650(height+delta+tail_metal,weight+2*delta,head_height+delta,head_weight+delta);
        translate([0,0,weight/3])
            cube([height+delta+tail_metal,weight+2*delta,weight*2/3],center=true);
    // 电池头凹槽   
        translate([height/2+tail_metal/2,0,head_weight/2])
            cube([(head_height+delta)*2,(head_weight+delta),(head_weight+delta)],center=true);
        translate([height/2+head_height+tail_metal/2+head_metal/2,0,0])
        rotate([0,90,0])
            cylinder(head_metal,r=weight/2,center=true);
    // 电池尾部凹槽   
        translate([-(height/2+tail_metal),0,0])
        rotate([0,90,0])
            union(){
                cylinder(head_metal,r=weight/2,center=true);
                translate([0,0,tail_metal/2])
                    cylinder(h=tail_metal,r=head_weight*3/5,center=true,$fn=100);
            }
    // 走线凹槽
        translate([0,(weight+thick)/2,weight/3-thick/2])
            cube([height+head_height+head_metal+tail_metal+thick*2,head_metal+delta,thick],center=true);
    }
}